Ext.namespace("GridCommunityInfo");
GridCommunityInfo.Detail = function() {
	this.userSelector = null;
	this.selectUserId = null;
	this.users = [];
	//社区id
	this.txtCommunityId = new Ext.form.Hidden({
		name:'CommunityId'
	});
	//营销单元id
	this.txtUnitId = new Ext.form.Hidden({
		name:'UnitId',
		value:''
	});
	//网格Id
	this.txtGridId = new Ext.form.Hidden({
		name:'GridId'
	});
	
	//社区名称
	this.txtCommunityName = new Ext.form.TextField({
		fieldLabel : '社区名称<font color="red">*</font>',
		name :'CommunityName',
		width : 120,
		maxLength : 10,
		allowBlank : false
	});
	//社区住宅楼数量
	this.txtBuildingNum = new Ext.form.NumberField({
		fieldLabel: '社区住宅楼数量',
		name : 'buildingNum',
		width: 80,
		maxLength : 8
	});
	//社区住宅楼楼层
	this.txtLayerDesc = new Ext.form.TextArea({
		fieldLabel : '社区住宅楼楼层 ',
		width : 400,
		height : 40,
		name : 'communityName',
		maxLength : 120
	});
	//社区开盘日期
    this.dfOpenDate = new Ext.form.DateField({
    	fieldLabel :'社区开盘日期:',
    	name : 'openDate',
    	labelSeparator: '',
		width: 120,
		format: 'Y-m-d'
	});
	//社区总户数
    this.txtTotalDoorNum = new Ext.form.NumberField({
		fieldLabel : '社区总户数<font color="red">*</font>',
		name : 'totalDoorNum',
		width : 120,
		maxLength : 8
	});
	//社区入住率
	this.txtOccupancyRate = new Ext.form.TextField({
		fieldLabel : '社区入住率',
		name :'occupancyRate',
		width : 120,
		maxLength : 10
	});
	//社区购房单价 
	this.txtHouseUnitPrice = new Ext.form.TextField({
		fieldLabel : '社区购房单价',
		name :'houseUnitPrice',
		width : 120,
		maxLength : 10
	});
	//社区是否有商铺
	this.cmbHasMerchant = new Ext.form.ComboBox({
        width: 120,
        fieldLabel: '社区是否有商铺',
        name : 'operatorsInfo.hasG',
        store: new Ext.data.SimpleStore({
        	fields: ['value', 'name'],
        	data: OMS.GRIDBUILDING_YESNO
        }),
        valueField: 'value',
        editable: false,
        displayField: 'name',
        typeAhead:true,
        mode: 'local',
        emptyText:'---请选择---',
        triggerAction: 'all',
        selectOnFocus: true
    });
    
    //社区商铺招商方向
	this.cmbAttractInvestment = new Ext.form.TextField({
        width: 120,
        fieldLabel: '社区商铺招商方向',
        maxLength : 10
    });
	//社区商铺单价
	this.txtMerchantUnitPrice = new Ext.form.NumberField({
		fieldLabel : '社区商铺单价',
		name :'merchantUnitPrice',
		width : 120,
		maxLength : 8
	});
	//社区车位数量
	this.txtGarageNum = new Ext.form.NumberField({
		fieldLabel : '社区车位数量',
		name :'garageNum',
		width : 120,
		maxLength : 8
	});
	//社区楼组数量
	this.txtBuildingGroupNum = new Ext.form.NumberField({
		fieldLabel : '社区楼组数量',
		name :'buildingGroupNum',
		width : 120,
		maxLength : 8
	});
	//客户经理ID
	this.txtUnitManagerUserId = new Ext.form.Hidden({
    	name : 'userId'
    });
	//客户经理
    this.txtUnitManager = new Ext.form.TextField({
		fieldLabel: '客户经理<font color="red">*</font>',
		readOnly: true,
		name : 'userName',
		width: 120,
		listeners: {
		'render': function(cmp) {
				var self = cmp.ownerCt.ownerCt.ownerCt.ownerCt.ownerCt;
				//console.info(self)
				cmp.getEl().on('click', self.showSelector, self); 
			}
		}
	});
	//联系方式
	 this.txtUnitManagerPhone = new Ext.form.NumberField({
    	fieldLabel : '联系方式',
    	name : 'userPhone',
		width : 120,
		maxLength : 15
    });
    //行政区县
	this.cmbProvince = new Ext.form.ComboBox({
		width : 120,
        fieldLabel : '行政区县<font color="red">*</font>',
//      hiddenName : 'addressInfo.province',
		editable: false,
        store: ['浦东新区'],
        typeAhead:true,
        mode: 'local',
        triggerAction: 'all',
        selectOnFocus: true	
	});
	//街道路段
	this.txtAddressInfoNeighbourhood = new Ext.form.TextField({
		fieldLabel : '街道路段',
		name : 'neighbourhood',
		width : 120,
		maxLength : 10
	});
	//地址-路
	this.txtAddressId = new Ext.form.Hidden({
		name : 'addressId'
	});
	this.txtAddressInfoStreet = new Ext.form.TextField({
		fieldLabel : '地址 路<font color="red">*</font>',
		name :'street',
		width : 120,
		maxLength : 10
	});
	//弄
	this.txtAddressInfoAlley = new Ext.form.NumberField({
		fieldLabel: '弄<font color="red">*</font>',
		name :'alley',
		width: 60,
		maxLength : 10
	});
	//号
	this.txtAddressInfoDoorNum = new Ext.form.NumberField({
		fieldLabel: '号<font color="red">*</font>',
		name :'doorNum',
		width: 60,
		maxLength : 10
	});
	//商用楼数
	this.businessBuildingNum = new Ext.form.NumberField({
		fieldLabel: '商用楼数<font color="red">*</font> ',
		name :'businessBuildingNum',
		width: 120,
		maxLength : 10
	});	
	//商铺数
	this.shopNum = new Ext.form.NumberField({
		fieldLabel: '商铺数<font color="red">*</font> ',
		name :'shopNum',
		width: 120,
		maxLength : 10
	});		
    //是否有铁通宽带资源
    this.isHaveCtt = new Ext.form.ComboBox({
        width: 120,
        fieldLabel: '是否有铁通宽带<font color="red">*</font> ',
        name : 'isHaveCtt',
        store: new Ext.data.SimpleStore({
        	fields: ['value', 'name'],
        	data: OMS.GRIDBUILDING_YESNO
        }),
        valueField: 'value',
        displayField: 'name',
        typeAhead:true,
        editable: false,
        mode: 'local',
        emptyText:'',
        triggerAction: 'all',
        selectOnFocus: true,
        forceSelection:true
    });
  //社区移动集团客户数
	this.mobileCompanyNum = new Ext.form.TextField({
		fieldLabel : '移动集团客户数<font color="red">*</font>  ',
		name : 'mobileCompanyNum',
		width : 120,
		maxLength : 100
	});
	//社区移动家庭客户数
	this.mobileFamilyNum = new Ext.form.TextField({
		fieldLabel : '移动家庭客户数<font color="red">*</font>  ',
		name : 'mobileFamilyNum',
		width : 120,
		maxLength : 100
	});
	//最近的营业厅名称
	this.nearlyHallName = new Ext.form.TextField({
		fieldLabel : '最近营业厅名称<font color="red">*</font> ',
		name : 'nearlyHallName',
		width : 120,
		maxLength : 100
	});
	//基本信息
	this.form = new Ext.form.FormPanel({
		bodyStyle : 'padding: 5px 5px 0',
		frame :true,
		//fileUpload: true, 
		autoScroll : true,
		//autoHeight : true,
		height: 390,
		width : 700,
		labelAlign: 'right',
		labelWidth : 120,
		layout : 'table',
		layoutConfig : {columns:2},
		items:[
			{layout:'form',items:[this.txtCommunityName]},
			{layout:'form',items:[this.txtBuildingNum]},
			{colspan:2,layout:'form',items:[this.txtLayerDesc]},
			{layout:'form', items:[this.dfOpenDate]},
            {layout:'form', items:[this.txtTotalDoorNum]},
            {layout:'form', items:[this.cmbHasMerchant]},
            {layout:'form', items:[this.cmbAttractInvestment]}, 
            {layout:'form', items:[this.txtOccupancyRate]},
            {layout:'form', items:[this.txtHouseUnitPrice]},
            {layout:'form', items:[this.txtMerchantUnitPrice]},
            {layout:'form', items:[this.txtGarageNum]},
            {layout:'form', items:[this.txtUnitManager]},
            //{layout:'form', items:[this.txtUnitManagerPhone]},
            {layout:'form', items:[this.txtBuildingGroupNum]}, 
            {rowspan:3,layout:'form',items:[
            			{layout:'form',items:this.txtAddressInfoStreet},
            			{layout:'form',items:this.txtAddressInfoAlley},
            			{layout:'form',items:this.txtAddressInfoDoorNum}
            			]},
            {layout:'form', items:[this.cmbProvince]},
            {layout:'form', items:[this.txtAddressInfoNeighbourhood]},
            {layout:'form', items:[this.txtGridId]},
            {layout:'form', items:[this.businessBuildingNum]},
            {layout:'form', items:[this.shopNum]},
            {layout:'form', items:[this.mobileCompanyNum]},
            {layout:'form', items:[this.isHaveCtt]},
            {layout:'form', items:[this.mobileFamilyNum]},
            {layout:'form', items:[this.nearlyHallName]},
            {layout:'form', items:[this.txtCommunityId]}
		]
	});
	////物业信息
    //楼宇物业公司名称 
    this.txtPropertyCompany = new Ext.form.Hidden({
    	name : 'propertyCompany'
    });
    
    this.txtCompanyInfoCustName  = new Ext.form.TextField({
    	fieldLabel : '物业公司名称<font color="red">*</font>',
    	name : 'custName',
		width : 120,
		maxLength : 25
    });
    
    //物业公司联系人1
    this.txtPmContactInfoContactId = new Ext.form .Hidden({
    	name : 'pmContactInfo.contactId'
    });
    this.txtPmContactInfoUserName = new Ext.form.TextField({
    	fieldLabel : '物业公司联系人1',
    	name : 'pmContactInfo.userName',
		width : 120,
		maxLength : 25
    });
    this.txtPmContactInfoPosition = new Ext.form.TextField({
    	fieldLabel : '联系人1职位',
    	name : 'pmContactInfo.position',
		width : 120,
		maxLength : 25
    });
    //办公电话
    this.txtPmContactInfoPhoneNumOffice = new Ext.form.NumberField({
    	fieldLabel : '联系人1办公电话',
    	name : 'pmContactInfo.phoneNumOffice',
		width : 120,
		maxLength : 15
    });
     //移动电话
   this.txtPmContactInfoMobileNumber = new Ext.form.NumberField({
    	fieldLabel : '联系人1移动电话',
    	name : 'pmContactInfo. ',
		width : 120,
		maxLength : 15
    });
    //物业公司物业公司联系人2
    this.txtPbContactInfoContactId = new Ext.form.Hidden({
    	name : 'pbContactInfo.contactId'
    });
    this.txtPbContactInfoUserName = new Ext.form.TextField({
    	fieldLabel : '物业公司联系人2',
    	name : 'pbContactInfo.userName',
		width : 120,
		maxLength : 25
    });
     this.txtPbContactInfoPosition = new Ext.form.TextField({
    	fieldLabel : '联系人2职位',
    	name : 'pbContactInfo.position',
		width : 120,
		maxLength : 25
    });
    //办公电话
    this.txtPbContactInfoPhoneNumOffice = new Ext.form.NumberField({
    	fieldLabel : '联系人2办公电话',
    	name : 'pbContactInfo.phoneNumOffice',
		width : 120,
		maxLength : 15
    });
     //移动电话
    this.txtPbContactInfoMobileNumber = new Ext.form.NumberField({
    	fieldLabel : '联系人2移动电话',
    	name : 'pbContactInfo.mobileNumber',
		width : 120,
		maxLength : 15
    });
    //物业公司联系人3
     this.txtPpContactInfoContactId = new Ext.form.Hidden({
    	name : 'ppContactInfo.contactId'
    });
    this.txtPpContactInfoUserName = new Ext.form.TextField({
    	fieldLabel : '物业公司联系人3',
    	name : 'ppContactInfo.userName',
		width : 120,
		maxLength : 25
    });
    this.txtPpContactInfoPosition = new Ext.form.TextField({
    	fieldLabel : '联系人3职位',
    	name : 'ppContactInfo.position',
		width : 120,
		maxLength : 25
    });
    
    //办公电话
    this.txtPpContactInfoPhoneNumOffice = new Ext.form.NumberField({
    	fieldLabel : '联系人3办公电话',
    	name : 'ppContactInfo.phoneNumOffice',
		width : 120,
		maxLength : 15
    });
     //移动电话
    this.txtPpContactInfoMobileNumber = new Ext.form.NumberField({
    	fieldLabel : '联系人3移动电话',
    	name : 'ppContactInfo.mobileNumber',
		width : 120,
		maxLength : 15
    });
    this.formFieldSet1 = new Ext.form.FieldSet({
	        title: '联系人1',
	        layout:'table',
	        autoHeight: true,
	        labelAlign:'right',
	        layoutConfig:{columns:2},
	        items:[
	        	{colspan:1,layout:'form', items:[this.txtPmContactInfoPosition]},
				{colspan:1,layout:'form', items:[this.txtPmContactInfoUserName]},
				{colspan:1,layout:'form', items:[this.txtPmContactInfoPhoneNumOffice]},
				{colspan:1,layout:'form', items:[this.txtPmContactInfoMobileNumber]},
				{colspan:1,layout:'form', items:[this.txtPmContactInfoContactId]}
			]
		});
	this.formFieldSet2 = new Ext.form.FieldSet({
	        title: '联系人2',
	        layout:'table',
	        autoHeight: true,
	        labelAlign:'right',
	        layoutConfig:{columns:2},
	        items:[
	       		{colspan:1,layout:'form', items:[this.txtPbContactInfoPosition]},
				{colspan:1,layout:'form', items:[this.txtPbContactInfoUserName]},
				{colspan:1,layout:'form', items:[this.txtPbContactInfoPhoneNumOffice]},
				{colspan:1,layout:'form', items:[this.txtPbContactInfoMobileNumber]},
				{colspan:1,layout:'form', items:[this.txtPbContactInfoContactId]}
			]
		});
	this.formFieldSet3 = new Ext.form.FieldSet({
	        title: '联系人3',
	        layout:'table',
	        autoHeight: true,
	        labelAlign:'right',
	        layoutConfig:{columns:2},
	        items:[
	        	{colspan:1,layout:'form', items:[this.txtPpContactInfoPosition]},
	        	{colspan:1,layout:'form', items:[this.txtPpContactInfoUserName]},
				{colspan:1,layout:'form', items:[this.txtPpContactInfoPhoneNumOffice]},
				{colspan:1,layout:'form', items:[this.txtPpContactInfoMobileNumber]},
				{colspan:1,layout:'form', items:[this.txtPpContactInfoContactId]}
			]
		});
    
    //物业信息---FormPanel
    this.contactInfoForm = new Ext.form.FormPanel({
		bodyStyle : 'padding: 5px 5px 0',
		frame :true,
		//autoHeight : true,
		height:420,
		align:'center',
		width : 700,
		labelAlign: 'right',
		labelWidth : 120,
		layout : 'table',
		layoutConfig : {columns:1},
		items:[
			{colspan:1,layout:'form', items:[this.txtCompanyInfoCustName]},
			{colspan:1,layout:'form', items:[this.txtPropertyCompany]},
			this.formFieldSet1,this.formFieldSet2,this.formFieldSet3
		]
	});
	
    
	//社区居委会信息
    this.txtNCId = new Ext.form.Hidden({
    	name : 'ncId'
    });
    //居委地址
    
	//行政区县
	this.cmbNCProvince = new Ext.form.ComboBox({
		width : 120,
        fieldLabel : '行政区县',
//      hiddenName : 'addressInfo.province',
        store: ['浦东新区'],
        typeAhead:true,
        editable: false,
        mode: 'local',
        triggerAction: 'all',
        selectOnFocus: true	
	});
	//街道路段
	this.txtNCAddressInfoNeighbourhood = new Ext.form.TextField({
		fieldLabel : '街道路段',
		name : 'neighbourhood',
		width : 120,
		maxLength : 10
	});
	//地址-路
	this.txtNCAddressId = new Ext.form.Hidden({
		name : 'addressId'
	});
	this.txtNCAddressInfoStreet = new Ext.form.TextField({
		fieldLabel : '地址 路',
		name :'street',
		width : 120,
		maxLength : 10
	});
	//弄
	this.txtNCAddressInfoAlley = new Ext.form.NumberField({
		fieldLabel: '弄',
		name :'alley',
		width: 60,
		maxLength : 10
	});
	//号
	this.txtNCAddressInfoDoorNum = new Ext.form.NumberField({
		fieldLabel: '号',
		name :'doorNum',
		width: 60,
		maxLength : 10
	});
    //管辖常驻人口
	 this.txtPermanentPopulation = new Ext.form.NumberField({
    	fieldLabel : '管辖常驻人口',
    	name : 'permanentPopulation',
		width : 120,
		maxLength : 8
    });
    //管辖居民户数
	 this.txtDoorNum = new Ext.form.NumberField({
    	fieldLabel : '管辖居民户数',
    	name : 'doorNum',
		width : 120,
		maxLength : 8
    });
    
    //居委会主任id
    this.txtNCLeaderId = new Ext.form.Hidden({
    	name : 'NCLeaderId'
    });
    //居委会主任
    this.txtNCLeader = new Ext.form.TextField({
    	fieldLabel: '居委会主任',
		name : 'ncLeader',
		width: 120,
		maxLength : 8
    });
    //联系电话
    this.txtNCLeaderPhoneNumOffice = new Ext.form.NumberField({
    	fieldLabel : '联系电话',
    	name : 'phoneNumOffice',
		width : 120,
		maxLength : 15
    });
    //居委会具体业务联系人id
     this.txtBusiContactId = new Ext.form.Hidden({
    	name : 'contactId'
    });
    //居委会具体业务联系人
    this.txtBusiContact = new Ext.form.TextField({
    	fieldLabel : '具体业务联系人',
    	name : 'busiContact',
		width : 120,
		maxLength : 8
    });
    
    //联系电话
    this.txtBusiContactPhoneNumOffice = new Ext.form.NumberField({
    	fieldLabel : '联系电话',
    	name : 'phoneNumOffice',
		width : 120,
		maxLength : 15
    });
    
	//社区居委活动频率
	this.txtActivityFrequency = new Ext.form.NumberField({
    	fieldLabel : '居委活动频率',
    	name : 'activityFrequency',
		width : 120,
		maxLength : 8
    });
     //社区居委活动类型
	this.txtActivityType = new Ext.form.ComboBox({
        width: 100,
        fieldLabel: '居委活动类型',
        name : 'ActivityType',
        store: new Ext.data.SimpleStore({
        	fields: ['value', 'name'],
        	data: OMS.GRID_NC_TYPE
        }),
        valueField: 'value',
        editable: false,
        displayField: 'name',
        typeAhead:true,
        mode: 'local',
        emptyText:'---请选择---',
        triggerAction: 'all',
        selectOnFocus: true
    });
		//居委会信息panel
     this.NCForm = new Ext.form.FormPanel({
		bodyStyle : 'padding: 5px 5px 0',
		frame :true,
		autoScroll : true,
		height: 390,
		align:'center',
		width : 700,
		labelAlign: 'right',
		labelWidth : 130,
		layout : 'table',
		layoutConfig : {columns:2},
		items:[		
			{layout:'form', items:[this.txtNCLeader]},
			{layout:'form', items:[this.txtNCLeaderPhoneNumOffice]},
			{layout:'form', items:[this.txtBusiContact]},
			{layout:'form', items:[this.txtBusiContactPhoneNumOffice]},
			{layout:'form', items:[this.txtPermanentPopulation]},
			{layout:'form', items:[this.txtDoorNum]},
			{layout:'form', items:[this.txtActivityType]},
            {layout:'form', items:[this.txtActivityFrequency]},
			{rowspan:3,layout:'form',items:[
            			{layout:'form',items:this.txtNCAddressInfoStreet},
            			{layout:'form',items:this.txtNCAddressInfoAlley},
            			{layout:'form',items:this.txtNCAddressInfoDoorNum}
            			]},
            {layout:'form', items:[this.cmbNCProvince]},
            {layout:'form', items:[this.txtNCAddressInfoNeighbourhood]},
            {layout:'form', items:[this.txtNCAddressId]}
		]
	});
	//GIS信息
	//片区属地
	/*this.cmbDistrict = new Ext.form.ComboBox({
        width: 150,
        listWidth : 167,
        fieldLabel: '片区属地',
        name : 'gridId',
		valueField : 'areaId',
		displayField :'name',
        mode: 'local',
        //typeAhead:true,
        emptyText:'------请选择------',
        triggerAction: 'all',
        selectOnFocus: true,
        store: new Ext.data.SimpleStore({
        	fields: ['value', 'name'],
        	data: OMS.GRID_NC_TYPE
        })
    });
    //社区经度 
    this.txtAddressInfoLongitude = new Ext.form.TextField({
    	fieldLabel : '社区经度',
    	name : 'longitude',
		width : 150
    });
    //社区纬度
    this.txtAddressInfoLatitude = new Ext.form.TextField({
    	fieldLabel : '社区纬度',
    	name : 'latitude',
		width : 150
    });

    //图标ID
    this.txtGisIconId = new Ext.form.Hidden({
    	name: 'gis.iconId'
    });*/
	
	//GIS_ID
    this.txtGisId = new Ext.form.Hidden({
    	name: 'gis.id'
    });
    
	//所属网格
	this.cmbGrid= new Ext.form.ComboBox({
		width :120,
		listWidth:135,
        fieldLabel: '所属网格',
        name : 'gridId',
        store : new Ext.data.JsonStore({
		   url:"../gridareas/listGrid.form",
		   autoLoad : true,
		   root:"grids",
		   fields:["gridId","gridName"]
		}),
		valueField : 'gridId',
		editable: false,
		displayField :'gridName',
        mode: 'local',
        //typeAhead:true,
        emptyText:'请选择所属网格',
        triggerAction: 'all',
        selectOnFocus: true
	});
	//所属区域
	this.cmbRegion = new Ext.form.ComboBox({
		width :120,
		listWidth:135,
		allowBlank : true,
		blankText:'请选择所属区域',
		fieldLabel: '所属区域',
		store : new Ext.data.JsonStore({
		   url:'../gridareas/listAllRegions.form',
		   autoLoad : true,
		   root:"regions",
		   fields:["areaId","name"]
		}),
		valueField : 'areaId',
		displayField :'name',
		editable: false,
        mode: 'local',
		triggerAction :'all',
		emptyText :'请选择所在区域',
		selectOnFocus :true	
	});
	//坐标
    this.txtCoordsInfo = new Ext.form.TextArea({
		fieldLabel : '社区坐标',
		preventScrollbars : true,
		name :'coordsInfo',
		width : 400,
		heigth : 350
    });
    
    this.txtGisType = new Ext.form.Hidden({
		name: 'gisInfo.type',
		value: 1
	});
	
	this.txtGroupCustInfoID = new Ext.form.Hidden({
    	name:'marketIdInfo'
    });
    
    //社区边框颜色
    this.txtLineColor = new Ext.form.ComboBox({
        width: 120,
        listWidth : 137,
        fieldLabel: '边框颜色',
        name : 'lineColor',
        mode: 'local',
        emptyText:'请选择颜色',
        triggerAction: 'all',
        editable: false,
        selectOnFocus: true,
        valueField: 'value',
        displayField: 'name',
        store: new Ext.data.SimpleStore({
        	fields: ['value', 'name'],
        	data: OMS.GIS_COLOR
        })
    });
    
    //社区填充颜色
    this.txtMainFillColor = new Ext.form.ComboBox({
        width: 120,
        listWidth : 137,
        fieldLabel: '填充颜色',
        name : 'mainFillColor',
        mode: 'local',
        emptyText:'请选择颜色',
        triggerAction: 'all',
        editable: false,
        selectOnFocus: true,
        valueField: 'value',
        displayField: 'name',
        store: new Ext.data.SimpleStore({
        	fields: ['value', 'name'],
        	data: OMS.GIS_COLOR
        })
    });

    //绘制社区
    this.btnDrawGis = new Ext.Button({
        text: '绘制社区',
        tooltip: {text: '绘制社区'},
        handler: this.viewGis,
        scope: this
    });
    
    //GIS信息--FormPanel
    this.gis_form = new Ext.form.FormPanel({
		bodyStyle : 'padding: 5px 5px 0',
		frame :true,
		//autoHeight : true,
		height:420,
		id:'gisForm',
		width : 700,
//		disabled: true,
		labelAlign: 'right',
		labelWidth : 120,
		layout : 'table',
		layoutConfig : {columns:2},
		items:[
			/*{colspan:2,layout:'form',items:[this.cmbDistrict]},
			{layout:'form', items:[this.txtAddressInfoLongitude]},
            {layout:'form', items:[this.txtAddressInfoLatitude]},
            {layout:'form', items:[this.txtGisIconId]},*/
			{layout:'form',items:[this.cmbRegion]},
			{layout:'form',items:[this.cmbGrid]},
			{layout:'form', items:[this.txtLineColor]},
			{layout:'form', items:[this.txtMainFillColor]},
			{colspan:2,layout:'form', items:[this.txtCoordsInfo]},
			{layout:'form', items:[this.txtGisType]},
            {colspan:2,layout:'form', items:[this.btnDrawGis]},
            {layout:'form', items:[this.txtGisId]}
		]
	});
	 this.tabs = new Ext.TabPanel({
        width:700,
        activeTab: 0,
        frame:true,
        //autoHeight:true,
        height : 420,
        deferredRender:false, 
		layoutOnTabChange:true,
        items:[
            {items:this.form, title: '基本信息'},
            {items:this.contactInfoForm, title: '物业信息'},
            {items:this.NCForm,title:'居委会信息'},
            {items:this.gis_form, title: 'Gis信息'}
        ]
    });
    
	GridCommunityInfo.Detail.superclass.constructor.call(this,{
		title : '社区信息',
		bodyStyle: 'padding: 5px 5px 0',
        autoHeight: true,
        width: 730,
        resizable: false,
        plain: true,
        modal: true,
        layout:'form',
        autoScroll: true,
        closeAction: 'hide',
        items :[this.tabs],
        buttons: [{
            text: '保存',
            cls: 'x-btn-text-icon btn-save',
            handler: this.onSave,
            scope: this
        }, {
            text: '关闭',
            cls: 'x-btn-text-icon btn-cancel',
            handler: this.hide.createDelegate(this, [])
        }]
	});
};

Ext.extend(GridCommunityInfo.Detail,Ext.Window,{
		initAdd :function(){
			this.form.getForm().reset();
			this.gis_form.getForm().reset();
			this.NCForm.getForm().reset();
			this.contactInfoForm.getForm().reset();
		},
		initEdit : function(data){
			this.form.getForm().reset();
			this.gis_form.getForm().reset();
			this.NCForm.getForm().reset();
			this.contactInfoForm.getForm().reset();
			Ext.Ajax.request({
				url: '../gridcommunityinfo/prepare.form?timesnap=' + Date.parse(new Date()),
				method: 'POST',
				scope:this,
				params: {
					community_id : data.COMMUNITY_ID,
					unit_manager : data.UNIT_MANAGER,
					gis_id : data.GIS_ID,
					address_id : data.ADDRESS_ID,
					unit_id : data.UNIT_ID,
					property_company : data.PROPERTY_COMPANY,
					nc_address:data.NC_ADDRESS
					//entity_id : data.ENTITY_ID
					//entity_type :data.ENTITY_TYPE,
					//contact_type : data.CONTACT_TYPE
				},
				success:function(resp){	
					var resp = Ext.util.JSON.decode(resp.responseText);
					
					//基本信息
					if(resp.community){
						this.txtCommunityId.setValue(resp.community[0].COMMUNITY_ID);
						this.txtUnitId.setValue(resp.community[0].UNIT_ID);
						this.txtGridId.setValue(resp.community[0].GRID_ID);
						this.txtCommunityName.setValue(resp.community[0].COMMUNITY_NAME);
						this.txtBuildingNum.setValue(resp.community[0].BUILDING_NUM);
						this.txtLayerDesc.setValue(resp.community[0].LAYER_DESC);
						this.dfOpenDate.setValue(resp.community[0].OPEN_DATE);
						this.txtTotalDoorNum.setValue(resp.community[0].TOTAL_DOOR_NUM);
						this.cmbHasMerchant.setValue(resp.community[0].HAS_MERCHANT);
						this.cmbAttractInvestment.setValue(resp.community[0].ATTRACT_INVESTMENT);
						this.txtOccupancyRate.setValue(resp.community[0].OCCUPANCY_RATE);
						this.txtHouseUnitPrice.setValue(resp.community[0].HOUSE_UNIT_PRICE);
						this.txtMerchantUnitPrice.setValue(resp.community[0].MERCHANT_UNIT_PRICE);
						this.txtGarageNum.setValue(resp.community[0].GARAGE_NUM);
						this.txtBuildingGroupNum.setValue(resp.community[0].BUILDING_GROUP_NUM);
						//新加项
						this.businessBuildingNum.setValue(resp.community[0].BUSINESS_BUILDING_NUM);
						this.shopNum.setValue(resp.community[0].SHOP_NUM);
						this.mobileCompanyNum.setValue(resp.community[0].MOBILE_COMPANY_NUM);
						this.mobileFamilyNum.setValue(resp.community[0].MOBILE_FAMILY_NUM);
						this.isHaveCtt.setValue(resp.community[0].IS_HAVE_CTT);
						
						
					}
					if(resp.unit_manager[0]){
						this.txtUnitManagerUserId.setValue(resp.unit_manager[0].USER_ID);
						this.txtUnitManager.setValue(resp.unit_manager[0].USER_NAME);
						this.txtUnitManagerPhone.setValue(resp.unit_manager[0].USER_PHONE);
					}
					if(resp.unit){
						this.txtAddressId.setValue(resp.unit[0].ADDRESS_ID);
						this.nearlyHallName.setValue(resp.unit[0].NEARLY_HALL_NAME);
						this.cmbRegion.setValue(resp.unit[0].AREA_ID);
						this.cmbGrid.setValue(resp.unit[0].GRID_ID);
					}
					if(resp.address[0]){
						this.txtAddressInfoStreet.setValue(resp.address[0].STREET);
						this.txtAddressInfoAlley.setValue(resp.address[0].ALLEY);
						this.txtAddressInfoDoorNum.setValue(resp.address[0].DOOR_NUM);
						this.cmbProvince.setValue(resp.address[0].DISTRICT);
						this.txtAddressInfoNeighbourhood.setValue(resp.address[0].NEIGHBOURHOOD);
					}
					//居委会信息
					if(resp.nc[0]){
						this.txtNCId.setValue(resp.nc[0].NC_ID);
						this.txtNCAddressId.setValue(resp.nc[0].NC_ADDRESS);
						this.txtPermanentPopulation.setValue(resp.nc[0].PERMANENT_POPULATION);
						this.txtDoorNum.setValue(resp.nc[0].DOOR_NUM);
						this.txtNCLeaderId.setValue(resp.nc[0].NC_LEADER);
						this.txtBusiContactId.setValue(resp.nc[0].BUSI_CONTACT);
						this.txtActivityType.setValue(resp.nc[0].ACTIVITY_TYPE);
						this.txtActivityFrequency.setValue(resp.nc[0].ACTIVITY_FREQUENCY);
					}
					if(resp.ncLeader){
						this.txtNCLeader.setValue(resp.ncLeader.USER_NAME);
						this.txtNCLeaderPhoneNumOffice.setValue(resp.ncLeader.PHONE_NUM_OFFICE);
					}
					if(resp.busiContact){
						this.txtBusiContact.setValue(resp.busiContact.USER_NAME);
						this.txtBusiContactPhoneNumOffice.setValue(resp.busiContact.PHONE_NUM_OFFICE);
					}
					if(resp.ncAddress[0]){
						this.txtNCAddressId.setValue(resp.ncAddress[0].ADDRESS_ID);
						this.txtNCAddressInfoStreet.setValue(resp.ncAddress[0].STREET);
						this.txtNCAddressInfoAlley.setValue(resp.ncAddress[0].ALLEY);
						this.txtNCAddressInfoDoorNum.setValue(resp.ncAddress[0].DOOR_NUM);
						this.cmbNCProvince.setValue(resp.ncAddress[0].DISTRICT);
						this.txtNCAddressInfoNeighbourhood.setValue(resp.ncAddress[0].NEIGHBOURHOOD);
					}
					//gis信息
					//this.cmbDistrict.setValue(resp.community[0].GRID);
					//this.txtAddressInfoLongitude.setValue(resp.address[0].LONGITUDE);
					//this.txtGisIconId.setValue(resp.gis[0].ICON_ID);
					//this.txtGridId.setValue(resp.gis[0].GRID_ID);
					if(resp.gis[0]){
						this.txtGisId.setValue(resp.gis[0].GIS_ID);
						this.txtCoordsInfo.setValue(resp.gis[0].COORDS_INFO);
						this.txtLineColor.setValue(resp.gis[0].LINE_COLOR);
						this.txtMainFillColor.setValue(resp.gis[0].MAIN_FILL_COLOR);
						this.txtGisType.setValue(resp.gis[0].TYPE);
					}
					//物业信息
					if(resp.property_company[0]){
						this.txtPropertyCompany.setValue(resp.property_company[0].CUST_ID);
						this.txtCompanyInfoCustName.setValue(resp.property_company[0].CUST_NAME);
					}
					if(resp.pmContactInfo){
						this.txtPmContactInfoContactId.setValue(resp.pmContactInfo.CONTACT_ID);
						this.txtPmContactInfoUserName.setValue(resp.pmContactInfo.USER_NAME);
						this.txtPmContactInfoPosition.setValue(resp.pmContactInfo.POSITION);
						this.txtPmContactInfoPhoneNumOffice.setValue(resp.pmContactInfo.PHONE_NUM_OFFICE);
						this.txtPmContactInfoMobileNumber.setValue(resp.pmContactInfo.MOBILE_NUMBER);
					}
					if(resp.pbContactInfo){
						this.txtPbContactInfoContactId.setValue(resp.pbContactInfo.CONTACT_ID);
						this.txtPbContactInfoPosition.setValue(resp.pbContactInfo.POSITION);
						this.txtPbContactInfoUserName.setValue(resp.pbContactInfo.USER_NAME);
						this.txtPbContactInfoPhoneNumOffice.setValue(resp.pbContactInfo.PHONE_NUM_OFFICE);
						this.txtPbContactInfoMobileNumber.setValue(resp.pbContactInfo.MOBILE_NUMBER);
					}
					if(resp.ppContactInfo){
						this.txtPpContactInfoContactId.setValue(resp.ppContactInfo.CONTACT_ID);
						this.txtPpContactInfoPosition.setValue(resp.ppContactInfo.POSITION);
						this.txtPpContactInfoUserName.setValue(resp.ppContactInfo.USER_NAME);
						this.txtPpContactInfoPhoneNumOffice.setValue(resp.ppContactInfo.PHONE_NUM_OFFICE);
						this.txtPpContactInfoMobileNumber.setValue(resp.ppContactInfo.MOBILE_NUMBER);
					}
				},
				failure:function(resp){	
					Utils.info('操作失败!','系统提示');
					return;
				}
			});
		},
		onSave:function(){
			if(!this.form.getForm().isValid()){
				Utils.info("信息填写不完整或有误,请检查!","系统提示");
				return;
			}
			this.conn =new Ext.data.Connection({
		        method: 'POST',
		        url: '../gridcommunityinfo/save.form?timesnap=' + Date.parse(new Date())
		    });
			Utils.request(this.conn,{
				scope: this,
				params: {
					//基本信息
					community_id:this.txtCommunityId.getValue(),
					unit_id:this.txtUnitId.getValue(),
					grid_id:this.txtGridId.getValue(),
					community_name:this.txtCommunityName.getValue(),
					building_num:this.txtBuildingNum.getValue(),
					layer_desc:this.txtLayerDesc.getValue(),
					open_date:this.dfOpenDate.getValue()?this.dfOpenDate.getValue().format('Y-m-d'):'',
					total_door_num:this.txtTotalDoorNum.getValue(),
					has_merchant:this.cmbHasMerchant.getValue(),
					attract_investment:this.cmbAttractInvestment.getValue(),
					occupancy_rate:this.txtOccupancyRate.getValue(),
					house_unit_price:this.txtHouseUnitPrice.getValue(),
					merchant_unit_price:this.txtMerchantUnitPrice.getValue(),
					garage_num:this.txtGarageNum.getValue(),
					building_group_num:this.txtBuildingGroupNum.getValue(),
					
					unit_manager_user_id:this.txtUnitManagerUserId.getValue(),
					unit_manager_user_name:this.txtUnitManager.getValue(),
					unit_manager_user_phone:this.txtUnitManagerPhone.getValue(),
					
					address_id:this.txtAddressId.getValue(),
					
					street:this.txtAddressInfoStreet.getValue(),
					alley:this.txtAddressInfoAlley.getValue(),
					door_num:this.txtAddressInfoDoorNum.getValue(),
					district:this.cmbProvince.getValue(),
					neighbourhood:this.txtAddressInfoNeighbourhood.getValue(),
					
					//新加的字段
					businessBuildingNum:this.businessBuildingNum.getValue(),
					shopNum:this.shopNum.getValue(),
					isHaveCtt:this.isHaveCtt.getValue(),
					mobileCompanyNum:this.mobileCompanyNum.getValue(),
					mobileFamilyNum:this.mobileFamilyNum.getValue(),
					nearlyHallName:this.nearlyHallName.getValue(),
					
					pmcontactinfo_user_name:this.txtPmContactInfoUserName.getValue(),
					pmcontactinfo_user_position:this.txtPmContactInfoPosition.getValue(),
					pmcontactinfo_phone_num_office:this.txtPmContactInfoPhoneNumOffice.getValue(),
					pmcontactinfo_mobile_number:this.txtPmContactInfoMobileNumber.getValue(),
					
					pbcontactinfo_user_name:this.txtPbContactInfoUserName.getValue(),
					pbcontactinfo_user_position:this.txtPbContactInfoPosition.getValue(),
					pbcontactinfo_phone_num_office:this.txtPbContactInfoPhoneNumOffice.getValue(),
					pbcontactinfo_mobile_number:this.txtPbContactInfoMobileNumber.getValue(),
					
					ppcontactinfo_user_name:this.txtPpContactInfoUserName.getValue(),
					ppcontactinfo_user_position:this.txtPpContactInfoPosition.getValue(),
					ppcontactinfo_phone_num_office:this.txtPpContactInfoPhoneNumOffice.getValue(),
					ppcontactinfo_mobile_number:this.txtPpContactInfoMobileNumber.getValue(),
					
					pmcontactinfo_contact_id:this.txtPmContactInfoContactId.getValue(),
					pbcontactinfo_contact_id:this.txtPbContactInfoContactId.getValue(),
					ppcontactinfo_contact_id:this.txtPpContactInfoContactId.getValue(),
								
					//居委会信息
					nc_id:this.txtNCId.getValue(),
					nc_address:this.txtNCAddressId.getValue(),
					permanent_population:this.txtPermanentPopulation.getValue(),
					nc_door_num:this.txtDoorNum.getValue(),
					nc_leader:this.txtNCLeaderId.getValue(),
					busi_contact:this.txtBusiContactId.getValue(),
					activity_type:this.txtActivityType.getValue(),
					activity_frequency:this.txtActivityFrequency.getValue(),
					
					nc_leader_user_name:this.txtNCLeader.getValue(),
					nc_leader_phone_num_office:this.txtNCLeaderPhoneNumOffice.getValue(),
					
					busi_contact_user_name:this.txtBusiContact.getValue(),
					busi_contact_phone_num_office:this.txtBusiContactPhoneNumOffice.getValue(),
					
					nc_address_street:this.txtNCAddressInfoStreet.getValue(),
					nc_address_alley:this.txtNCAddressInfoAlley.getValue(),
					nc_address_door_num:this.txtNCAddressInfoDoorNum.getValue(),
					nc_address_district:this.cmbNCProvince.getValue(),
					nc_address_neighbourhood:this.txtNCAddressInfoNeighbourhood.getValue(),
					
					//gis信息
					//grid_id:this.cmbDistrict.getValue(),
					//grid_id:this.txtGridId.getValue(),
					//icon_id:this.txtGisIconId.getValue(),
					grid_id:this.cmbGrid.getValue(),
					area_id:this.cmbRegion.getValue(),
					gis_id:this.txtGisId.getValue(),
					coords_info : this.txtCoordsInfo.getValue(),
					line_color : this.txtLineColor.getValue(),
					main_fill_color : this.txtMainFillColor.getValue(),
					type : this.txtGisType.getValue(),
					groupCustInfoID:this.txtGroupCustInfoID.getValue(),
					
					//物业信息
					property_company:this.txtPropertyCompany.getValue(),
					property_company_cust_id:this.txtPropertyCompany.getValue(),
					property_company_cust_name:this.txtCompanyInfoCustName.getValue()
				},
				success:function(resp){	
					this.scope.hide();
					GridCommunityInfo.List.instance.store.reload();
				}
			});
		},
		showSelector: function(event) {
			if (!this.userSelector) {
				this.userSelector = new Selector.User(this, '客户经理');
			}
			//console.info(this.users);
			this.userSelector.initUsers(this.users);
			this.userSelector.show();
		},
		
		setUsers: function(o) {	// for Selector.User callback
			if(o.length>0){
				this.users = o;
				this.txtUnitManager.setValue(this.users[0].name);
				this.txtUnitManagerUserId.setValue(this.users[0].id);
				this.selectUserId = this.users[0].id;
			}
		},
		initGridGis:function(lineColor,mainFillColor,gridName,coordInfo,groupCustInfoID,gridId){
			this.txtLineColor.setValue(lineColor);
			this.txtMainFillColor.setValue(mainFillColor);
			this.txtCommunityName.setValue(gridName);
			this.txtCoordsInfo.setValue(coordInfo);
			this.txtGroupCustInfoID.setValue(groupCustInfoID);//社区当中所包含的集团客户ID集
			this.txtGridId.setValue(gridId);
			
		},
		viewGis:function(){
			var unitId = this.txtUnitId.getValue();
			var areaId = this.cmbRegion.getValue();
			var layerType;
			if(unitId==null||unitId==""){
				unitId = 0;
				layerType = 1;
				if(areaId==''){
					Utils.warn('请先选择区域！');
					return;
				}
			}else{
				layerType = 2;
			}
			
			var str = OMS.GIS_IP+'/gis_for_management.jsp?areaId=' + areaId + '&lineColor=' + this.txtLineColor.getValue() + 
			'&mainFillColor=' + this.txtMainFillColor.getValue() + 
			'&name='+this.txtCommunityName.getValue()+
			'&type=1'+
			'&did='+unitId+ 
			'&coordx='+this.txtCoordsInfo.getValue()+ '&layerType='+layerType;
			window.open(encodeURI(str), '_blank', 'toolbar=no,location=no,directories=no,scrollbars=no,menubar=no,width=1000,height=600,resizable=no,left=0,top=0, status=no');	
		}
		
});

//社区GIS 回调函数
 function initGridGis(lineColor,mainFillColor,gridName,coordInfo,groupCustInfoID,gridId){
	GridCommunityInfo.Detail.instance.initGridGis(lineColor,mainFillColor,gridName,coordInfo,groupCustInfoID,gridId);
};